package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbAdminMapper;
import com.dongdongshop.model.TbAdmin;
import com.dongdongshop.model.TbAdminExample;
import com.dongdongshop.service.AdminService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Resource
    private TbAdminMapper tbAdminMapper;

    @Override
    public TbAdmin getAdminByName(String username) {
        TbAdminExample tbAdminExample = new TbAdminExample();
        TbAdminExample.Criteria criteria = tbAdminExample.createCriteria();
        criteria.andUnameEqualTo(username);
        List<TbAdmin> tbAdmins = tbAdminMapper.selectByExample(tbAdminExample);
        return tbAdmins == null || tbAdmins.isEmpty() ? null : tbAdmins.get(0);
    }
}
